package cn.edu.zafu.bigdata.x.sxy;

import java.io.*;
import java.net.Socket;

public class DemoClient {
    public static void main(String[] args) throws IOException {
        String serip = "192.168.16.38"; // 服务端ip地址
        int prot = 3000;
        Socket socket = new Socket(serip, prot);

        BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
        BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));

        String userInput;
        System.out.println("Connected, you can enter 'exit' to quit.");

        while ((userInput = stdIn.readLine())!= null){
            if ("exit".equalsIgnoreCase(userInput)){
                break;
            }
            out.println(userInput);
            System.out.println("Server reponse " + in.readLine());
        }
        stdIn.close();
        in.close();
        out.close();
        socket.close();
    }
}
